import moment from 'moment';
// 命名规范：Arr普通枚举  field下拉字段枚举  Map表格字段枚举

// 表头筛选字段
const headerForm = {};
// 表格字段
const tableColumn = {
  // 所有题目表格列表
  questTableMap: [
    {
      prop: 'id',
      label: 'ID',
      type: 'text',
    },
    {
      prop: 'questionTitle',
      label: '题目',
      tooltip: true,
      type: 'text',
    },
    {
      prop: 'categoryName',
      label: '题库',
      type: 'text',
    },
    {
      prop: 'questionTypeName',
      label: '题型',
      type: 'text',
    },
    {
      prop: 'themeNames',
      label: '主题',
      type: 'text',
    },
    {
      prop: 'attrTypeName',
      label: '属性题型',
      type: 'text',
    },
    {
      prop: 'specifiedRangeStr',
      label: '指定范围',
      type: 'text',
    },
    {
      prop: 'statusStr',
      label: '状态',
      type: 'text',
    },
    {
      prop: 'createTime',
      label: '创建时间',
      type: 'text',
      width: 160
    },
    {
      prop: 'updateTime',
      label: '更新时间',
      type: 'text',
      width: 160
    },
  ],
  zhQuestGroupTableMap: [
    {
      prop: 'id',
      label: 'ID',
      type: 'text',
    },
    {
      prop: 'groupName',
      label: '组别名称',
      type: 'text',
    },
    {
      prop: 'statusStr',
      label: '状态',
      type: 'text',
    },
    {
      prop: 'createTime',
      label: '创建时间',
      type: 'text',
    },
    {
      prop: 'updateTime',
      label: '更新时间',
      type: 'text',
    },
  ]
};
// 表单字段
const editForm = {
  // 题库基础组件表单
  basicQuestEditMap: [
    {
      prop: 'questionTitle',
      type: 'input',
      label: '题目',
      col: 24,
    },
    {
      prop: 'questionImages',
      type: 'upload',
      style: 'input',
      label: '图片',
      customClass: 'inputUpload',
      col: 12,
    },
    {
      prop: 'questionVideoFiles',
      type: 'upload',
      label: '视频',
      style: 'input',
      accept: 'video/*',
      customClass: 'inputUpload',
      col: 12,
    },
    {
      prop: 'questionAudioFiles',
      type: 'upload',
      label: '音频',
      style: 'input',
      accept: 'audio/*',
      customClass: 'inputUpload',
      col: 12,
    },
    {
      prop: 'questionUrl',
      type: 'input',
      label: '链接',
      col: 12,
    },
    {
      prop: 'questionTypeManagementId',
      type: 'select',
      label: '题型',
      optionDynamic: {
        apiKey: 'questionAllQuestOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'typeName',
      col: 12,
    },
    {
      prop: 'questionContent',
      type: 'textarea',
      label: '文案',
      row: 5,
      col: 24,
    },
    {
      prop: 'categoryId',
      type: 'select',
      label: '题库分类',
      optionDynamic: {
        apiKey: 'questionQuestTypeOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'categoryName',
      col: 12,
    },
    {
      prop: 'themeId',
      stringProp: 'themeIds',
      type: 'select',
      label: '主题',
      multiple: true,
      collapse: false,
      optionDynamic: {
        apiKey: 'questionQuestThemeOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'themeName',
      col: 12,
    },
    {
      prop: 'specifiedRange',
      type: 'radio',
      label: '指定范围',
      optionKey: 'GENDER_RANGE',
      col: 12,
    },
    {
      prop: 'matchSwitch',
      type: 'radio',
      label: '是否参与匹配',
      optionKey: 'JOIN_MATCH',
      col: 12,
    },
    {
      prop: 'isDirectional',
      type: 'switch',
      label: '是否定向答题',
      activeValue: '1',
      inactiveValue: '0',
      col: 12,
    },
    {
      prop: 'isContradiction',
      type: 'switch',
      label: '是否矛盾题',
      optionKey: 'JOIN_MATCH',
      activeValue: '1',
      inactiveValue: '0',
      col: 12,
    },
    {
      prop: 'matchSwitchVisble',
      type: 'switchButton',
      label: '',
      text: '编辑条件',
      switchProp: 'isDirectional',
      col: 12,
      action: 'visibleButton',
      customClick: function (prop, action, { _this }) {
        if (prop === 'matchSwitchVisble' && action === 'visibleButton') {
          _this.$set(_this.editFormData, 'matchSwitchVisble', true);
          _this.$emit('clickAction', {
            action,
          });
        }
      },
    },
    {
      prop: 'requiredQuestionsId',
      type: 'switchSelect',
      label: '必答题',
      switchProp: 'isContradiction',
      optionDynamic: {
        apiKey: 'questionAnswerQuestOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'questionTitle',
      col: 12,
    },
  ],
  // 必答题额外多出来的字段
  bdQuestEditMap:[
    {
      prop: 'labelId',
      labelProp: 'labelName',
      type: 'select',
      label: '题库标签',
      optionDynamic: {
        apiKey: 'questionLabelOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'labelName',
      col: 12,
    },
  ],
  // 题库定向答题组件表单
  directedQuestEditMap: [
    {
      prop: 'addr',
      type: 'cascader',
      label: '所在地区',
      clearable: true,
      filterable: true,
      labelCustomClass: 'requiredFormItem',
      optionDynamic: {
        apiKey: 'AreaListOption',
        params: {},
        methods: 'get',
      },
      optionMode: 'tree',
      optionValue: 'id',
      optionLabel: 'name',
      optionChildName: 'chirdList',
    },
    {
      prop: 'jobId',
      stringProp: 'jobIds',
      // labelProp: 'job',
      type: 'select',
      label: '工作范围',
      multiple: true,
      clearable: true,
      filterable: true,
      optionDynamic: {
        apiKey: 'JobOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'jobName',
    },
    {
      prop: 'age',
      type: 'inputRange',
      label: '年龄',
      children: [
        {
          prop: 'ageMin',
          type: 'inputNumber',
          label: '最小值',
        },
        {
          prop: 'separator',
          type: 'separator',
          label: '-',
          col: 4,
        },
        {
          prop: 'ageMax',
          type: 'inputNumber',
          label: '最大值',
        },
      ],
      col: 12,
    },
    {
      prop: 'height',
      type: 'inputRange',
      label: '身高',
      children: [
        {
          prop: 'heightMin',
          type: 'inputNumber',
          label: '最小值',
        },
        {
          prop: 'separator',
          type: 'separator',
          label: '-',
          col: 4,
        },
        {
          prop: 'heightMax',
          type: 'inputNumber',
          label: '最大值',
        },
      ],
      col: 12,
    },
    {
      prop: 'weight',
      type: 'inputRange',
      label: '体重',
      children: [
        {
          prop: 'weightMin',
          type: 'inputNumber',
          label: '最小值',
        },
        {
          prop: 'separator',
          type: 'separator',
          label: '-',
          col: 4,
        },
        {
          prop: 'weightMax',
          type: 'inputNumber',
          label: '最大值',
        },
      ],
      col: 12,
    },
    {
      prop: 'appearance',
      type: 'inputRange',
      label: '颜值',
      children: [
        {
          prop: 'appearanceMin',
          type: 'inputNumber',
          label: '最小值',
        },
        {
          prop: 'separator',
          type: 'separator',
          label: '-',
          col: 4,
        },
        {
          prop: 'appearanceMax',
          type: 'inputNumber',
          label: '最大值',
        },
      ],
      col: 12,
    },
    {
      prop: 'educationId',
      stringProp: 'educationIds',
      type: 'select',
      label: '学历',
      multiple: true,
      clearable: true,
      filterable: true,
      optionDynamic: {
        apiKey: 'EduOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'eduName',
    },
    {
      prop: 'zodiacId',
      stringProp: 'zodiacIds',
      type: 'select',
      label: '属相',
      multiple: true,
      clearable: true,
      filterable: true,
      optionDynamic: {
        apiKey: 'ZodiacOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'zodiacName',
    },
    {
      prop: 'salaryId',
      stringProp: 'salaryIds',
      type: 'select',
      label: '收入',
      multiple: true,
      clearable: true,
      filterable: true,
      optionDynamic: {
        apiKey: 'SalaryOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'salaryName',
    },
    {
      prop: 'marriageStatu',
      stringProp: 'marriageStatus',
      type: 'select',
      label: '婚姻状态',
      multiple: true,
      clearable: true,
      filterable: true,
      optionKey: 'MARRY_STATUS',
    },
    {
      prop: 'isCar',
      type: 'select',
      label: '是否购车',
      clearable: true,
      filterable: true,
      optionKey: 'CAR_BUY_STATUS',
    },
    {
      prop: 'isHouse',
      type: 'select',
      label: '是否购房',
      clearable: true,
      filterable: true,
      optionKey: 'HOUSE_BUY_STATUS',
    },
  ],
  // 所有题目筛选表单
  questFilterMap: [
    {
      prop: 'questionTitle',
      type: 'input',
      label: '题目',
      col: 0,
      width: 100,
    },
    {
      prop: 'questionTypeManagementId',
      type: 'select',
      label: '题型',
      clearable: true,
      filterable: true,
      optionDynamic: {
        apiKey: 'questionAllQuestOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'typeName',
      col: 0,
      width: 100,
    },
    {
      prop: 'categoryId',
      type: 'select',
      label: '题库分类',
      clearable: true,
      filterable: true,
      optionDynamic: {
        apiKey: 'questionQuestTypeOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'categoryName',
      col: 0,
      width: 100,
    },
    {
      prop: 'specifiedRange',
      type: 'select',
      label: '指定范围',
      clearable: true,
      filterable: true,
      optionKey: 'GENDER_RANGE',
      col: 0,
      width: 100,
    },
    {
      prop: 'status',
      type: 'select',
      label: '状态',
      optionKey: 'COVERT_STATUS',
      col: 0,
      width: 100,
    },
    {
      prop: 'createTime',
      startProp: 'createTimeStartTime',
      endProp: 'createTimeEndTime',
      label: '创建时间',
      type: 'datePicker',
      dateType: 'datetimerange',
      format: 'yyyy-MM-dd HH:mm:ss',
      valueFormat: 'yyyy-MM-dd HH:mm:ss',
      pickerOptions: {
        disabledDate: function (time) {
          return time.getTime() > moment().format('x');
        },
      },
      clearable: true,
      width: 100,
      col: 0,
      xs: 12,
      sm: 12,
      md: 8,
      lg: 8,
      xl: 6,
    },
    {
      prop: 'updateTime',
      startProp: 'updateTimeStartTime',
      endProp: 'updateTimeEndTime',
      label: '更新时间',
      type: 'datePicker',
      dateType: 'datetimerange',
      format: 'yyyy-MM-dd HH:mm:ss',
      valueFormat: 'yyyy-MM-dd HH:mm:ss',
      pickerOptions: {
        disabledDate: function (time) {
          return time.getTime() > moment().format('x');
        },
      },
      clearable: true,
      width: 100,
      col: 0,
      xs: 12,
      sm: 12,
      md: 8,
      lg: 8,
      xl: 6,
    },
  ],
  // 组合题筛选表单
  zhQuestGroupFilterMap: [
    {
      prop: 'groupName',
      type: 'input',
      label: '组别名称',
      col: 0
    },
    {
      prop: 'status',
      type: 'select',
      label: '状态',
      optionKey: 'COVERT_STATUS',
      col: 0
    },
    {
      prop: 'createTimeStartTime',
      label: '创建开始时间',
      type: 'datePicker',
      dateType: 'datetimerange',
      format: 'yyyy-MM-dd HH:mm:ss',
      valueFormat: 'yyyy-MM-dd HH:mm:ss',
      pickerOptions: {
        disabledDate: function (time) {
          return time.getTime() > moment().format('x');
        },
      },
      clearable: true,
      col: 0
    },
    {
      prop: 'createTimeEndTime',
      label: '创建结束时间',
      type: 'datePicker',
      dateType: 'datetimerange',
      format: 'yyyy-MM-dd HH:mm:ss',
      valueFormat: 'yyyy-MM-dd HH:mm:ss',
      pickerOptions: {
        disabledDate: function (time) {
          return time.getTime() > moment().format('x');
        },
      },
      clearable: true,
      col: 0
    },
    {
      prop: 'updateTimeStartTime',
      label: '更新开始时间',
      type: 'datePicker',
      dateType: 'datetimerange',
      format: 'yyyy-MM-dd HH:mm:ss',
      valueFormat: 'yyyy-MM-dd HH:mm:ss',
      pickerOptions: {
        disabledDate: function (time) {
          return time.getTime() > moment().format('x');
        },
      },
      clearable: true,
      col: 0
    },
    {
      prop: 'updateTimeEndTime',
      label: '更新结束时间',
      type: 'datePicker',
      dateType: 'datetimerange',
      format: 'yyyy-MM-dd HH:mm:ss',
      valueFormat: 'yyyy-MM-dd HH:mm:ss',
      pickerOptions: {
        disabledDate: function (time) {
          return time.getTime() > moment().format('x');
        },
      },
      clearable: true,
      col: 0
    },
  ],
  // 组合题组别新增/修改表单
  zhQuestGroupEditMap: [
    {
      prop: 'groupName',
      type: 'input',
      label: '组别名称',
      col: 24
    },
    {
      prop: 'status',
      type: 'select',
      label: '状态',
      optionKey: 'COVERT_STATUS',
      col: 24
    },
  ],
};
// 其他映射
const otherMap = {};
// 表单字段校验
const editRule = {
  // 题库基础组件校验
  basicQuestFormRule: {
    questionTitle: [{ required: true, message: '请填写题目', trigger: 'blur' }],
    questionTypeManagementId: [{ required: true, message: '请选择题型', trigger: 'change' }],
    categoryId: [{ required: true, message: '请选择题库分类', trigger: 'change' }],
    labelId: [{ required: true, message: '请选择题库标签', trigger: 'change' }],
    themeId: [{ type: 'array', required: true, message: '请选择主题', trigger: 'change' }],
    specifiedRange: [{ required: true, message: '请选择指定范围', trigger: 'change' }],
    matchSwitch: [{ required: true, message: '请选择是否参与匹配', trigger: 'change' }],
    isDirectional: [{ required: true, message: '请选择是否定向答题', trigger: 'change' }],
    isContradiction: [{ required: true, message: '请选择是否矛盾题', trigger: 'change' }],
  },
  // 组合题组别校验
  zhQuestGroupFormRule: {
    groupName: [{ required: true, message: '请填写组别名称', trigger: 'blur' }],
    status: [{ required: true, message: '请选择状态', trigger: 'change' }],
  },
};
export default {
  headerForm,
  tableColumn,
  editForm,
  otherMap,
  editRule,
};
